package com.cnap.multiclouldmgmt.controller;

import com.cnap.multiclouldmgmt.MulticlouldmgmtApplicationTests;
import com.cnap.multiclouldmgmt.model.k8sModels.NameSpaceModel;
import com.cnap.multiclouldmgmt.model.k8sModels.NodeModel;
import com.cnap.multiclouldmgmt.model.k8sModels.SvcModel;
import com.cnap.multiclouldmgmt.model.k8sModels.WorkLoadModel;
import com.cnap.multiclouldmgmt.service.K8sClusterService;
import com.cnap.multiclouldmgmt.service.OperationLogService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;

import static org.junit.jupiter.api.Assertions.*;

class K8sClusterControllerTest extends MulticlouldmgmtApplicationTests {

    @MockBean
    private K8sClusterService k8sClusterService;

    @MockBean
    private OperationLogService operationLogService;

    @Autowired
    private K8sClusterController k8sClusterController;

    @Test
    void getK8sClusterNodeInfos() {

        try{

            k8sClusterController.getK8sClusterNodeInfos("",
                "clustername","'keyword", 100, 1,null);

        }catch (Exception e){

        }

        try{

            k8sClusterController.getK8sClusterNodeInfos("",
                    "","'keyword", 100, 1,null);

        }catch (Exception e){

        }

        k8sClusterController.getK8sClusterNodeInfos("aliyun",
                "clustername","'keyword",
        100, 1,null);
    }

    @Test
    void addK8sClusterNode() {

        try{
            k8sClusterController.addK8sClusterNode(null);

        }catch (Exception e){

        }

        NodeModel nodeModel = new NodeModel();
        nodeModel.setNodeName("nodeName01");
        k8sClusterController.addK8sClusterNode(nodeModel);

    }

    @Test
    void editK8sClusterNodeInfo() {
        try {
            k8sClusterController.editK8sClusterNodeInfo(null);
        }catch (Exception e){

        }

        NodeModel nodeModel = new NodeModel();
        nodeModel.setNodeName("nodeName01");
        k8sClusterController.editK8sClusterNodeInfo(nodeModel);


    }

    @Test
    void delK8sClusterNode() {

        k8sClusterController.delK8sClusterNode("1.1.1.1","nodename");
    }

    @Test
    void getK8sClusterNameSpaces() {

        try{
            k8sClusterController.getK8sClusterNameSpaces("","clustername",
                    "",100,1,null);
        }catch (Exception e){

        }
        try{
            k8sClusterController.getK8sClusterNameSpaces("aliyun","",
                    "",100,1,null);
        }catch (Exception e){

        }


        k8sClusterController.getK8sClusterNameSpaces("aliyun","clustername",
                "",100,1,null);

    }

    @Test
    void addK8sClusterNameSpaces() {

        try {
            k8sClusterController.addK8sClusterNameSpaces(null);
        }catch (Exception e){

        }

        NameSpaceModel nameSpaceModel = new NameSpaceModel();
        nameSpaceModel.setNameSpaceName("ns01");
        k8sClusterController.addK8sClusterNameSpaces(nameSpaceModel);

    }

    @Test
    void delK8sClusterNameSpaces() {

        k8sClusterController.delK8sClusterNameSpaces("aliyun","clustername",
                "aaa");

    }

    @Test
    void getK8sClusterWorkLoads() {

        k8sClusterController.getK8sClusterWorkLoads("aliyun","clustername",
                "aaa","svc",100,1,null);
    }

    @Test
    void addK8sClusterWorkLoad() {
        WorkLoadModel workLoadModel = new WorkLoadModel();
        try{
            k8sClusterController.addK8sClusterWorkLoad(workLoadModel);
        }catch (Exception e){

        }

        workLoadModel.setCloudVendor("aliyun");
        try{
            k8sClusterController.addK8sClusterWorkLoad(workLoadModel);
        }catch (Exception e){

        }
        workLoadModel.setWorkLoadName("name");
        k8sClusterController.addK8sClusterWorkLoad(workLoadModel);


    }

    @Test
    void editK8sClusterWorkLoadReplicas() {

        WorkLoadModel workLoadModel = new WorkLoadModel();
        k8sClusterController.editK8sClusterWorkLoadReplicas(workLoadModel);
    }

    @Test
    void editK8sClusterWorkLoadContainers() {

        WorkLoadModel workLoadModel = new WorkLoadModel();
        k8sClusterController.editK8sClusterWorkLoadContainers(workLoadModel);
    }

    @Test
    void editK8sClusterWorkLoadYaml() {
        WorkLoadModel workLoadModel = new WorkLoadModel();
        k8sClusterController.editK8sClusterWorkLoadYaml(workLoadModel);
    }

    @Test
    void delK8sClusterWorkLoad() {

        k8sClusterController.delK8sClusterWorkLoad("","","","","");
    }

    @Test
    void getK8sClusterPods() {

        k8sClusterController.getK8sClusterPods("a","b","c","d","e","f",
                1,100,null);


        k8sClusterController.getK8sClusterPods("","b","c","d","e","f",
                1,100,null);
        k8sClusterController.getK8sClusterPods("a","","c","d","e","f",
                1,100,null);
    }

    @Test
    void delK8sClusterPod() {

        k8sClusterController.delK8sClusterPod("","","","");
    }

    @Test
    void getK8sClusterPodContainers() {
        k8sClusterController.getK8sClusterPodContainers("","","","");
    }

    @Test
    void getK8sClusterSvcs() {
        k8sClusterController.getK8sClusterSvcs("a","b","c",1,10,null);
        k8sClusterController.getK8sClusterSvcs("","b","c",1,10,null);
        k8sClusterController.getK8sClusterSvcs("a","","c",1,10,null);


    }

    @Test
    void addK8sClusterSvc() {
        SvcModel svcModel = new SvcModel();
        k8sClusterController.addK8sClusterSvc(svcModel);

        svcModel.setCloudVendor("aliyun");
        k8sClusterController.addK8sClusterSvc(svcModel);

        svcModel.setK8sClusterName("clustername");
        k8sClusterController.addK8sClusterSvc(svcModel);
        
    }

    @Test
    void editK8sClusterSvc() {

        SvcModel svcModel = new SvcModel();
        k8sClusterController.editK8sClusterSvc(svcModel);
        svcModel.setSvcName("test");
        k8sClusterController.editK8sClusterSvc(svcModel);
    }

    @Test
    void delK8sClusterSvc() {

        k8sClusterController.delK8sClusterSvc("","","","");
    }

    @Test
    void getK8sClusterMasterNodeNum() {
        k8sClusterController.getK8sClusterMasterNodeNum("11","");
        k8sClusterController.getK8sClusterMasterNodeNum("11","11");

    }
}